from com.kjssoft.common.ant.sercurity.sha256 import SHA256
from settings.settings import SECRET_KEY

__author__ = 'KJS'

class RainbowConsts(object):
    APP_NAME = 'rainbow'

class RainbowAllowedFileTypeConsts(object):
    IMAGE_FILE_CONTENT_TYPE_BMP = 'image/bmp'
    IMAGE_FILE_CONTENT_TYPE_PNG = 'image/png'
    IMAGE_FILE_CONTENT_TYPE_JPEG = 'image/jpeg'
    IMAGE_FILE_CONTENT_TYPE_GIF = 'image/gif'

    IMAGE_FILE_CONTENT_TYPES = (
        IMAGE_FILE_CONTENT_TYPE_BMP,
        IMAGE_FILE_CONTENT_TYPE_PNG,
        IMAGE_FILE_CONTENT_TYPE_JPEG,
        IMAGE_FILE_CONTENT_TYPE_GIF,
    )

class RainbowProfileConsts(object):
    ADMIN_GROUP = 'RAINBOW_ADMIN_GROUP'

class PhotoFrameConsts(object):
    class Layout(object):
        SINGLE_PHOTO_PER_FRAME        = 0
        V_LIST_FRAME                  = 1
        DOUBLE_LINE_FRAME             = 2
        MAIN_TOP_DOUBLE_LINE_FRAME    = 3
        MAIN_BOTTOM_DOUBLE_LINE_FRAME = 4

        @classmethod
        def get_choices(cls):
            return (
                (cls.SINGLE_PHOTO_PER_FRAME,        'SINGLE_PHOTO_PER_FRAME'),
                (cls.V_LIST_FRAME,                  'V_LIST_FRAME'),
                (cls.DOUBLE_LINE_FRAME,             'DOUBLE_LINE_FRAME'),
                (cls.MAIN_TOP_DOUBLE_LINE_FRAME,    'MAIN_TOP_DOUBLE_LINE_FRAME'),
                (cls.MAIN_BOTTOM_DOUBLE_LINE_FRAME, 'MAIN_BOTTOM_DOUBLE_LINE_FRAME'),
            )

    class Category(object):
        CELL = 0
        FRAME = 1
        ALBUM = 2

        @classmethod
        def get_choices(cls):
            return (
                (cls.CELL,  'CELL'),
                (cls.FRAME, 'FRAME'),
                (cls.ALBUM, 'ALBUM'),
            )

    class Status(object):
        DRAFT     = 0
        SUBMIT    = 1
        VERIFYING = 2
        VERIFIED  = 3
        REJECTED  = 4
        DELETED   = 5

        @classmethod
        def get_choices(cls):
            return (
                (cls.DRAFT,     'DRAFT'),
                (cls.SUBMIT,    'SUBMIT'),
                (cls.VERIFYING, 'VERIFYING'),
                (cls.VERIFIED,  'VERIFIED'),
                (cls.REJECTED,  'REJECTED'),
                (cls.DELETED,   'DELETED'),
            )

        @classmethod
        def get_values(cls):
            return (
                cls.DRAFT,
                cls.SUBMIT,
                cls.VERIFYING,
                cls.VERIFIED,
                cls.REJECTED,
                cls.DELETED,
            )

        @classmethod
        def encode_sha256_value(cls, value, secret):
            secret = '%s_%s' % (secret, SECRET_KEY)
            return SHA256().sha256_encode(str(value), secret)

        @classmethod
        def encode_sha256_values(cls, secret):
            secret_values = {
                'DRAFT'     : SHA256().sha256_encode(str(cls.DRAFT), secret),
                'SUBMIT'    : SHA256().sha256_encode(str(cls.SUBMIT), secret),
                'VERIFYING' : SHA256().sha256_encode(str(cls.VERIFYING), secret),
                'VERIFIED'  : SHA256().sha256_encode(str(cls.VERIFIED), secret),
                'DELETED'   : SHA256().sha256_encode(str(cls.DELETED), secret),
            }
            return secret_values

    class Scope(object):
        SELF   = 0
        FRIEND = 1
        PUBLIC = 2

        @classmethod
        def get_choices(cls):
            return (
                (cls.SELF,   'SELF'),
                (cls.FRIEND, 'FRIEND'),
                (cls.PUBLIC, 'PUBLIC'),
            )

        @classmethod
        def get_values(cls):
            return (
                cls.SELF,
                cls.FRIEND,
                cls.PUBLIC
            )

        @classmethod
        def encode_sha256_values(cls, secret):
            secret_values = {
                'SELF'   : SHA256().sha256_encode(str(cls.SELF), secret),
                'FRIEND' : SHA256().sha256_encode(str(cls.FRIEND), secret),
                'PUBLIC' : SHA256().sha256_encode(str(cls.PUBLIC), secret),
                }
            return secret_values

    class ErrorCode(object):
        UPLOAD_PHOTO_DATA_ERROR  = 1001
        PHOTO_FRAME_EXIST        = 1002

        PHOTO_FRAME_IS_NOT_EXIST = 1003

        PHOTO_FRAME_STATUS_NOT_ALLOWED_TO_ADD_COMMENT = 2001

        PHOTO_FRAME_RESET_STATUS_NOT_ALLOWED = 3001

    class ViewErrorCode(object):
        PHOTO_FRAME_COMMENT_SUBMIT_DATA_ERROR = 11001
        PHOTO_FRAME_SUBMIT_DATA_ERROR = 11002

        PHOTO_FRAME_RESET_STATUS_NOT_ALLOWED = 12001

class PhotoFrameCommentConsts(object):
    class Status(object):
        EFFICIENT = 1
        DELETED   = 0

        @classmethod
        def get_choices(cls):
            return (
                (cls.EFFICIENT, 'EFFICIENT'),
                (cls.DELETED,   'DELETED'),
            )